package com.usian.admin.controller.v1;


import com.usian.admin.service.WemediaNewsAutoService;
import com.usian.common.dtos.PageResult;
import com.usian.common.dtos.ResponseResult;
import com.usian.model.admin.dtos.NewsAuthDto;
import com.usian.model.media.dtos.WmNewsResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news_auth")
public class NewsAuthController {
    @Autowired
    private WemediaNewsAutoService wemediaNewsAutoService;

//    分页查询自媒体文章信息
    @PostMapping("/list")
    public PageResult<WmNewsResultDTO> findWmNewsPage(@RequestBody NewsAuthDto dto){
        return wemediaNewsAutoService.findWmNewsPage(dto);
    }

    /**
     * 根据id查询自媒体文章
     */
    @GetMapping("/one/{id}")
    public ResponseResult<WmNewsResultDTO> findById(@PathVariable("id")Integer id){
        return wemediaNewsAutoService.findWmNewsById(id);
    }

//    人工审核通过
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
        wemediaNewsAutoService.updateWmNews(dto.getId(),"审核通过",4);
        return ResponseResult.ok();
    }

//    人工审核失败
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        wemediaNewsAutoService.updateWmNews(dto.getId(),dto.getMsg(),2);
        return ResponseResult.ok();
    }
}
